﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using DotNetX.Regex;

namespace DotNetX
{
    public static class StringExtensions
    {
        public static string StripHtml(this String s)
        {
            return RegexHelper.StripHtml(s);
        }

        public static int ToInt32OrZero(this String s)
        {
            return ((object)s).ToInt32OrZero();
        }

        public static int ToInt32OrDefault(this String s, int def)
        {
            return ((object)s).ToInt32OrDefault(def);
        }

        public static float ToFloatOrZero(this String s)
        {
            return ((object)s).ToFloatOrZero();
        }

        public static float ToFloatOrDefault(this String s, float def)
        {
            return ((object)s).ToFloatOrDefault(def);
        }

        public static bool ToBooleanOrDefault(this String s, bool def)
        {
            return ((object)s).ToBooleanOrDefault(def);
        }

        public static string ToEmptyStringIfNull(this String s)
        {
            if (String.IsNullOrEmpty(s))
                return String.Empty;
            else
                return s;
        }
    }
}
